<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">


        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>巡检信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enginid" class="layui-input enginid" onclick="openPage('../public/choose_engin.php?dom=enginid&page=engin_cha','80%','80%')">
                            <div class="choose_div" id="enginid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin.php?dom=enginid&page=engin_cha','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>检查类型</label>
                        <div class="layui-input-block">
                            <div id="chatype"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>检查人</label>
                        <div class="layui-input-block">
                            <input type="text" name="chaer" id="chaer" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>检查日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="chadt" id="chadt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea"><text>*</text>检查概况</label>
                        <div class="layui-input-block">
                            <textarea id="chagai" name="chagai" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">存在问题</label>
                        <div class="layui-input-block">
                            <textarea id="cunwen" name="cunwen" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>是否需整改</label>
                        <div class="layui-input-block">
                            <select id="isxu" name="isxu" lay-filter="isxu" >
                                <option value="是">是</option>
                                <option value="否" selected>否</option>
                            </select>
                            <p class="error" id="isxu_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>


            <div class="isxu_info layui-hide">
                <div class="layui-form-item height_auto">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label label_textarea">整改要求</label>
                            <div class="layui-input-block">
                                <textarea id="gaiqiu" name="gaiqiu" placeholder="请输入" class="layui-textarea"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md6">
                            <label class="layui-form-label">整改负责人</label>
                            <div class="layui-input-block">
                                <input type="text" name="gaier" id="gaier" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label">要求完成日期</label>
                            <div class="layui-input-block">
                                <input type="text" name="yaodt" id="yaodt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label"><text>*</text>是否已整改</label>
                            <div class="layui-input-block">
                                <select id="iszheng" name="iszheng" lay-filter="iszheng" >
                                    <option value="是">是</option>
                                    <option value="否" selected>否</option>
                                </select>
                                <p class="error" id="iszheng_error" style="margin: 0;"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="iszheng_info layui-hide">
                    <div class="layui-form-item">
                        <div class="layui-row layui-col-space10">
                            <div class="layui-col-md12">
                                <label class="layui-form-label">整改完成日期</label>
                                <div class="layui-input-block">
                                    <input type="text" name="zhengdt" id="zhengdt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item height_auto">
                        <div class="layui-row layui-col-space10">
                            <div class="layui-col-md12">
                                <label class="layui-form-label label_textarea">整改情况说明</label>
                                <div class="layui-input-block">
                                    <textarea id="gaishuo" name="gaishuo" placeholder="请输入" class="layui-textarea"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联流程</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>

    </div>
</form>
<script>
    var param_enginid = getQueryVariable('enginid') || 0;

    $("#commentForm").validate({
        rules: {
            chaer: {required: true},
            chadt: {required: true},
            chagai: {required: true},
        },
        messages:{
            chaer: {required: "请输入"},
            chadt: {required: "请输入"},
            chagai: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_add_engin_cha, data:{enginid:param_enginid}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                $("#number").val(data.number);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                }



                var engininfo = res.data.engininfo;
                if(engininfo){
                    set_choose_btn('enginid',engininfo.id,engininfo.name);

                }

                xmselect_dan('chatype', res.data.chatype, '', function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#chatype").find('xm-select').removeClass('error');
                    }else{
                        $("#chatype").find('xm-select').addClass('error');
                    }
                });


                public_upload_file_load('upload_files', res.data.files);
                render_from();
                render_date();
                initParseMoney();
            }
        });

        form.on('select(isxu)', function(data){
            if(data.value == ''){
                $('#isxu_error').show().text('请选择');
                $('#isxu_error').parent().find('input').addClass('select_error');
            }else{
                $('#isxu_error').hide();
                $('#isxu_error').parent().find('input').removeClass('select_error');
            }
            if(data.value == '是'){
                $(".isxu_info").removeClass('layui-hide');
            }else{
                $(".isxu_info").addClass('layui-hide');
            }
        });
        form.on('select(iszheng)', function(data){
            if(data.value == ''){
                $('#iszheng_error').show().text('请选择');
                $('#iszheng_error').parent().find('input').addClass('select_error');
            }else{
                $('#iszheng_error').hide();
                $('#iszheng_error').parent().find('input').removeClass('select_error');
            }
            if(data.value == '是'){
                $(".iszheng_info").removeClass('layui-hide');
            }else{
                $(".iszheng_info").addClass('layui-hide');
            }
        });



        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');

            data.field.enginid = get_choose_val('enginid');
            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                formValid('enginid');
                if(data.field.enginid == undefined || !data.field.enginid){
                    validRes = false;
                }

                if(!data.field.chatype){
                    $("#chatype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#chatype").find('xm-select').removeClass('error');
                }

                if(data.field.isxu == ''){
                    $('#isxu_error').show().text('请选择');
                    $('#isxu_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#isxu_error').hide();
                    $('#isxu_error').parent().find('input').removeClass('select_error');
                }

                if(data.field.iszheng == ''){
                    $('#iszheng_error').show().text('请选择');
                    $('#iszheng_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#iszheng_error').hide();
                    $('#iszheng_error').parent().find('input').removeClass('select_error');
                }

                if(!validRes){return false;}
            }




            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);
            public_flow_submit(data.field, ask_flowdata_add_engin_cha, ask_flowdata_edit_engin_cha, $(this).attr('but'));
            return false;
        });

    });


</script>
</body>
</html>
